package com.example.ywj.toutiao.utils;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.ywj.toutiao.R;

import java.util.List;

public class MyEmojiAdapter extends BaseAdapter {
    public List<Integer> list;
    public MyEmojiAdapter(List<Integer> list){
        this.list = list;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder ;
        if(convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(parent.getContext());
            convertView = inflater.inflate(R.layout.emoji_item_layout, null);
            viewHolder = new ViewHolder();
            viewHolder.tv1 = convertView.findViewById(R.id.item_emoji);
            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.tv1.setText(convertView.getResources().getString(list.get(position)));
        return convertView;
    }
    class ViewHolder{
        TextView tv1;
    }
}
